<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ include file="/page/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%@ include file="/adapter/adapter-bootstrap.jsp" %>
<link href="${pageContext.request.contextPath}/frontframe/easyui/themes/easyui-extend.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
function save(){
	if(!checkData()){
		return false;
	}
	var str_data=$("#form1 input").map(function(){
		   return ($(this).attr("name")+'='+$(this).val());
		 }).get().join("&") ;
    $.ajax({
        url:"${ctx}/appDic/updateDic",
        type: "POST",      
        dataType:"json",
        data: str_data,
        async: false,
        success: function(data) {
        	if(data.flag>0){
	            alert("保存成功！");	
	           // window.location.href="${ctx}/auth/appNoticeList?appid=${appid}";
        	}
        },
        error: function() {
          alert("error");
        }
      });
}

function checkData(){
	var enName=document.getElementById("enName").value;
	if(enName==""){
		alert("字典项值不能为空！");
		return false;
	}
	//限制不能输入汉字和非法符号
	var reg=/^[a-zA-Z0-9_]+$/;
	var str=enName.match(reg);
	if(str==null){
		alert("字典项值的数据类型错误！");
		return false;
	}
	var optType=document.getElementById("optType").value;
	if(optType==""){
		alert("字典项值不能为空！");
		return false;
	}
	return true;
}

function  goBack(){
	window.history.back(-1);
}
</script>
</head>
<body>
     <div class="panel panel-default">
   <div class="panel-heading">
      <h3 class="panel-title">
          	修改数据字典
      </h3>
   </div>
   <div class="panel-body">
              <form class="form-horizontal" role="form"  id="form1">
                       <div class="form-group">
                          <label class="col-xs-2 control-label" for="enName">字典项值</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="enName" name="enName" type="text" readonly="readonly" value="${appDic.enName}"/>
                          </div>  
                          <label class="col-xs-2 control-label" for="optType">字典项</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="optType" name="optType" type="text" value="${appDic.optType}" placeholder=""/>
                          </div>                         
                       </div>
                       <div class="form-group">
                          <label class="col-xs-2 control-label" for="cnName">字典项值描述</label>
                          <div class="col-xs-4">
                             <input class="form-control" id="cnName" name="cnName" type="text"   value="${appDic.cnName}" />
                          </div> 
                       </div>
                       <div class="form-group  text-center">
                            <button type="button" class="btn btn-default"  onclick="save();">保存</button>
                            <button type="button" class="btn btn-default"   onclick="goBack()">返回</button>
                      </div>
             </form>
	</div>
	</div>

</body>
</html>
